class EditorElementConstructor {

    static className() {
        return 'EditorElementConstructor';
    }

    constructor() {
        this._isReady = false;
    }

    static sharedInstance() {
        if (!window.SharedEditorElementConstructor) {
            window.SharedEditorElementConstructor = new this();
        }
        return window.SharedEditorElementConstructor;
    }

    static constructorWithClassName(className) {
        this.sharedInstance().initial();
        return this.sharedInstance().constructors[className];
    }

    get isReady() {
        return this._isReady;
    }

    set isReady(value) {
        this._isReady = value;
    }

    get constructors() {
        if (!this._constructors) {
            this._constructors = {};
        }
        return this._constructors;
    }

    initial() {
        if (!this.isReady) {
            // 通用
            const {Rect, Point, Size} = require('./rect');
            const {Line} = require('./line');
            this.constructors["Rect"] = Rect;
            this.constructors["Point"] = Point;
            this.constructors["Size"] = Size;
            this.constructors["Line"] = Line;

            const {EditorData} = require('./editor-data');
            this.constructors["EditorData"] = EditorData;
            // 谱子部分
            const {MusicScoreData} = require('../../music-score/js/music-score-data');
            const {MusicScoreHeader} = require('../../music-score/js/music-score-header');
            const {MusicScoreText} = require('../../music-score/js/music-score-text');
            const {MusicScoreFuPuBiao} = require('../../music-score/js/music-score-fu-pu-biao');
            const {MusicScoreDanPuBiao} = require('../../music-score/js/music-score-dan-pu-biao');
            const {MusicScoreInstrument} = require('../../music-score/js/music-score-instrument');
            const {MusicScoreXiaoJie} = require('../../music-score/js/music-score-xiao-jie');
            const {MusicScoreXiaoJieXian} = require('../../music-score/js/music-score-xiao-jie-xian');
            const {MusicScoreFanFuSymbols} = require('../../music-score/js/music-score-fan-fu-symbols');
            const {MusicScoreDuanLuoQuFen} = require('../../music-score/js/music-score-duan-luo-qu-fen');
            const {MusicScoreShengBu} = require('../../music-score/js/music-score-sheng-bu');
            const {MusicScoreYinFu} = require('../../music-score/js/music-score-yin-fu');
            const {MusicScoreYinFuContent} = require('../../music-score/js/music-score-yin-fu-content');
            const {MusicScoreLianYin} = require('../../music-score/js/music-score-lian-yin');
            const {MusicScoreIndex} = require('../../music-score/js/music-score-index');
            const {MusicScoreLianYinXian} = require('../../music-score/js/music-score-lian-yin-xian');
            const {MusicScoreLianPuHao} = require('../../music-score/js/music-score-lian-pu-hao');
            const {MusicScoreYinFuZuHe} = require('../../music-score/js/music-score-yin-fu-zu-he');
            const {MusicScoreYiYin} = require('../../music-score/js/music-score-yi-yin');
            const {MusicScoreBaDu} = require('../../music-score/js/music-score-ba-du');
            const {MusicScoreTaBan} = require('../../music-score/js/music-score-ta-ban');
            const {MusicScoreQiangRuo} = require('../../music-score/js/music-score-qiang-ruo');
            const {MusicScoreHuaYinLine} = require('../../music-score/js/music-score-hua-yin-line');
            const {MusicScoreTr} = require('../../music-score/js/music-score-tr');
            const {MusicScorePuHao} = require('../../music-score/js/music-score-pu-hao');
            const {MusicScoreDiaoHao} = require('../../music-score/js/music-score-diao-hao');
            const {MusicScorePaiHao, PaiHaoContent} = require('../../music-score/js/music-score-pai-hao');
            const {MusicScoreYinFuSymbols, MusicSocreSymbol} = require('../../music-score/js/music-score-yin-fu-symbols');
            const {MusicScoreSymbolPaYin} = require('../../music-score/js/music-score-symbol-pa-yin');
            const {MusicScorePaiSu} = require('../../music-score/js/music-score-xiao-jie-pai-su');
            const {MusicScoreYinFuContentSymbols, MusicScoreYinFuContentSymbolsObject} = require('../../music-score/js/music-score-yin-fu-content-symbols');
            const {MusicScoreGeCi} = require('../../music-score/js/music-score-ge-ci');
            const {MusicScoreGeCiBox} = require('../../music-score/js/music-score-ge-ci-box');
            const {UILianYinXian} = require('../../music-score/js/ui-lian-yin-xian');
            const {UISpecialSymbol} = require('../../music-score/js/ui-special-symbol');
            const {UIBaDu} = require('../../music-score/js/ui-ba-du');
            const {UITaBan} = require('../../music-score/js/ui-ta-ban');
            const {UIChanYin} = require('../../music-score/js/ui-chan-yin');
            const {UIHuaYinLine} = require('../../music-score/js/ui-hua-yin-line');
            const {UIQiangRuo} = require('../../music-score/js/ui-qiang-ruo');
            const {UIDuanLuoQuFen} = require('../../music-score/js/ui-duan-luo-qu-fen');
            const MusicScoreSelectedInfoData = require('../../music-score/js/music-score-selected-arrange-data');  //多选音符删除类
            this.constructors["MusicScoreData"] = MusicScoreData;
            this.constructors["MusicScoreHeader"] = MusicScoreHeader;
            this.constructors["MusicScoreText"] = MusicScoreText;
            this.constructors["MusicScoreFuPuBiao"] = MusicScoreFuPuBiao;
            this.constructors["MusicScoreDanPuBiao"] = MusicScoreDanPuBiao;
            this.constructors["MusicScoreXiaoJie"] = MusicScoreXiaoJie;
            this.constructors["MusicScoreXiaoJieXian"] = MusicScoreXiaoJieXian;
            this.constructors["MusicScoreFanFuSymbols"] = MusicScoreFanFuSymbols;
            this.constructors["MusicScoreDuanLuoQuFen"] = MusicScoreDuanLuoQuFen;
            this.constructors["MusicScoreShengBu"] = MusicScoreShengBu;
            this.constructors["MusicScoreYinFu"] = MusicScoreYinFu;
            this.constructors["MusicScoreYinFuContent"] = MusicScoreYinFuContent;
            this.constructors["MusicScoreInstrument"] = MusicScoreInstrument;
            this.constructors["MusicScoreLianYin"] = MusicScoreLianYin;
            this.constructors["MusicScoreIndex"] = MusicScoreIndex;
            this.constructors["MusicScoreLianYinXian"] = MusicScoreLianYinXian;
            this.constructors["MusicScoreLianPuHao"] = MusicScoreLianPuHao;
            this.constructors["MusicScoreYinFuZuHe"] = MusicScoreYinFuZuHe;
            this.constructors["MusicScoreYiYin"] = MusicScoreYiYin;
            this.constructors["MusicScoreBaDu"] = MusicScoreBaDu;
            this.constructors["MusicScoreHuaYinLine"] = MusicScoreHuaYinLine;
            this.constructors["MusicScoreTaBan"] = MusicScoreTaBan;
            this.constructors["MusicScoreQiangRuo"] = MusicScoreQiangRuo;
            this.constructors["MusicScoreTr"] = MusicScoreTr;
            this.constructors["MusicScorePuHao"] = MusicScorePuHao;
            this.constructors["MusicScoreDiaoHao"] = MusicScoreDiaoHao;
            this.constructors["MusicScorePaiHao"] = MusicScorePaiHao;
            this.constructors["PaiHaoContent"] = PaiHaoContent;
            this.constructors["MusicScoreGeCi"] = MusicScoreGeCi;
            this.constructors["MusicScoreGeCiBox"] = MusicScoreGeCiBox;
            this.constructors["UILianYinXian"] = UILianYinXian;
            this.constructors["UISpecialSymbol"] = UISpecialSymbol;
            this.constructors["UIHuaYinLine"] = UIHuaYinLine;
            this.constructors["UIBaDu"] = UIBaDu;
            this.constructors["UITaBan"] = UITaBan;
            this.constructors["UIChanYin"] = UIChanYin;
            this.constructors["UIQiangRuo"] = UIQiangRuo;
            this.constructors["UIDuanLuoQuFen"] = UIDuanLuoQuFen;

            this.constructors["MusicScorePaiSu"] = MusicScorePaiSu;
            this.constructors["MusicScoreYinFuSymbols"] = MusicScoreYinFuSymbols;
            this.constructors["MusicSocreSymbol"] = MusicSocreSymbol;
            this.constructors["MusicScoreSymbolPaYin"] = MusicScoreSymbolPaYin;
            this.constructors["MusicScoreYinFuContentSymbols"] = MusicScoreYinFuContentSymbols;
            this.constructors["MusicScoreSelectedInfoData"] = MusicScoreSelectedInfoData;   //多选音符删除类
            this.constructors["MusicScoreYinFuContentSymbolsObject"] = MusicScoreYinFuContentSymbolsObject;

            // 画板部分
            const {SketchpadData} = require('../../sketchpad/js/sketchpad-data');
            const {SketchpadPath} = require('../../sketchpad/js/sketchpad-path');
            const {SketchpadText} = require('../../sketchpad/js/sketchpad-text');
            const {SketchpadMedia} = require('../../sketchpad/js/sketchpad-media');
            this.constructors["SketchpadData"] = SketchpadData;
            this.constructors["SketchpadPath"] = SketchpadPath;
            this.constructors["SketchpadText"] = SketchpadText;
            this.constructors["SketchpadMedia"] = SketchpadMedia;
            this.isReady = true;
        }
    }
}

module.exports = {
    EditorElementConstructor,
    SharedEditorElementConstructor: EditorElementConstructor.sharedInstance()
};